#include <iostream>

int main() {
    int a = 123456789;
    short b = static_cast<short>(a&0xffff);
    std::cout << "a&0xffff: " << (a & 0xffff) << std::endl;
    std::cout << "a: " << a << std::endl;
    std::cout << "b: " << b << std::endl;

    char c = 128;
    std::cout << "c: " << c << std::endl;

	a = 1;
	printf("a: %d  %x\n", a, a);

	a = -1;
	printf("a: %d  %x\n", a, a);

	a = -1<<1;
	printf("a: %d  %x\n", a, a);

	short d = -136;
	printf("d: %hd, %hx, %x, %x", d, d, (unsigned char)(d>>8 & 0xff), (unsigned char)(d&0xff));

    return 0;
}
